package client.comm.baoding.adapter

import android.content.Context
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.GoodsDetailTrade
import client.comm.baoding.databinding.LayoutGuadItemBinding
import client.comm.commlib.base.BaseAdapter
import client.comm.commlib.base.BindingViewHoder

class GuadanSlAdapter : BaseAdapter<GoodsDetailTrade.Order> {

    constructor(context: Context) : super(context) {
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.layout_guad_item,
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val binding = (holder as BindingViewHoder<LayoutGuadItemBinding>).binding
        val item = getItem(position)
        binding.event = this
        binding.bean = item

//        if(type==1){
//            binding.stateTv.setBackgroundResource(R.drawable.circle_red_bg_seq)
//        }else{
//            binding.stateTv.setBackgroundResource(R.drawable.circle_green_bg_seq)
//        }
//        binding.tv.text = item
    }

    var onZhaiDan: ((e: GoodsDetailTrade.Order) -> Unit)? = null

    fun onZhaiDan(e: GoodsDetailTrade.Order) {
        onZhaiDan?.invoke(e)
    }

}